---
id: oops
title: 4. Oops 静态类
sidebar_label: 4. Oops 静态类
---

## 4.1 抛出字符串异常

```cs
throw Oops.Oh("异常消息");
throw Oops.Oh("异常消息：{0}", "出错了");
```

## 4.2 指定类型的异常

```cs
throw Oops.Oh("异常消息", typeof(ArgumentNullException));
throw Oops.Oh("异常消息：{0}", typeof(ArgumentNullException), "出错了");
```

## 4.3 状态码异常

```cs
throw Oops.Oh(1000);
throw Oops.Oh(1000, "出错了");
```

## 4.4 状态码异常

```cs
throw Oops.Oh(1000, typeof(ArgumentNullException));
throw Oops.Oh(1000, typeof(ArgumentNullException), "出错了");
```

## 4.5 异常方法重试

```cs
Oops.Retry(() => {
    // Do.....
}, 3, 1000);

// 带返回值
var value = Oops.Retry<int>(() => {
    // Do.....
}, 3, 1000);

// 只有特定异常才监听
Oops.Retry(() => {

}, 3, 1000, typeof(ArgumentNullException));
```
